17. Negative Cups of Coffee

Quiz Intro Video

28q_Negative Number of Cups of Coffee

Side Note: You can put a ‘return’ keyword inside of an if statement, and that that will end the method early. See the highest rated answer in this StackOverflow post.

Hint: Check this guide on how to pop up toast messages in an app.

When the user tries to order too FEW coffees, what method will you need to modify?

SOLUTION: decrement

For the method above, which condition(s) could you use for the If Statement?

if (**condition**)
SOLUTION:
  • quantity == 1
  • quantity < 2

When the user tries to order too MANY coffees, what method will you need to modify?

SOLUTION: increment

For the method above, which condition(s) could you use for the If Statement?

if(**condition**)
SOLUTION:
  • quantity>=100
  • quantity==100

Solution Video

28s_Negative Number of Cups of Coffee